<template>
	<view class="agreement">
		<custom-nav v-bind="navConfig" :navStyle="{marginBottom: 0}" />
		<u-parse :content="content" />
	</view>
</template>

<script>
	import navConfig from './config/navConfig.js'
	import richTextConfig from './config/richTextConfig.js'

	export default {
		data() {
			return {
				navConfig,
				richTextConfig,
				content: ''
			};
		},
		onLoad({opt}) {
			console.log(opt, 'opt')
			const {
				type
			} = JSON.parse(opt)
			console.log(type, 'type')
			this.initNavigation(type)
			this.getRichText(type)
		},
		methods: {
			initNavigation(type) {
				switch (type) {
					case 'USER_PAY':
						this.navConfig.title = '购买协议'
						console.log(richTextConfig, 'richTextConfig')
						this.content = richTextConfig.USER_PAY
						uni.setNavigationBarTitle({
							title: '购买协议'  // 设置页面标题
						});
						break;
					case 'USER_AGREEMENT':
						this.navConfig.title = '用户协议'
						uni.setNavigationBarTitle({
							title: '用户协议'  // 设置页面标题
						});
						break;
					case 'PRIVACY_POLICY':
						this.navConfig.title = '隐私政策'
						uni.setNavigationBarTitle({
							title: '隐私政策'  // 设置页面标题
						});
						break;
				}
			},
			// 获取富文本
			getRichText(type) {
				this.content = richTextConfig[type]
			}
		}
	}
</script>
<style lang="scss" scoped>

</style>